package com.mlf.singleton.singleton.demo;

/**
 * 静态内部类实现 - 推荐
 */
public class InnerClassSingleton {
    private InnerClassSingleton() {
    }

    // 静态内部类在第一次使用时才会加载
    public static class SingleHolder {
        private static final InnerClassSingleton INSTANCE = new InnerClassSingleton();
    }

    public static InnerClassSingleton getInstance(){
        return SingleHolder.INSTANCE;
    }
    public void showMessage() {
        System.out.println("Hello from InnerClassSingleton!");
    }
}
